package org.springblade.common.utils;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public class MoneyUtil {

    public static String getMechOutTradeNo() {
        int random = ThreadLocalRandom.current().nextInt(10, 99);
        Date date = new Date();
        DateFormat format = new SimpleDateFormat("yyMMddHHmm");
        String time = format.format(date);
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV < 0) {
            hashCodeV = -hashCodeV;
        }
        String mechOutTradeNo = "M" + time + String.format("%011d", hashCodeV) + random;
        return mechOutTradeNo;
    }

    public static int correctYuanToFen(BigDecimal decimalYuan) {
        return decimalYuan.movePointRight(2).intValue();
    }
//
//    public static void main(String[] args) {
//        BigDecimal big = new BigDecimal("0.35");
//        System.out.println(correctYuanToFen(big));
//    }

}
